<?php

// Si le fichier de qui dÔøΩfinie les constantes n'a pas encore ÔøΩtÔøΩ appelÔøΩ on le charge
if (!defined('CONFIGURATION_FILE_LOADED'))
    include('includes/configuration_include.php');


include( PATH_VIEWS . 'profiles_view.php');
include( PATH_MODELS . 'profiles_model.php');

$bdd = model_db_connexion();

$req = model_profiles($bdd);

if (isset($_GET['details']) && $_GET['details'] >= 0 && is_numeric($_GET['details'])) {

    $details = $_GET['details'];
    $req = model_one_profile($bdd, $details);

    while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) {
        $profile = $donnees['id_user'];
        $user_login = $donnees['user_login'];
        $user_name = $donnees['user_name'];
        $user_surname = $donnees['user_surname'];
        $user_description = $donnees['user_description'];
        $user_email = $donnees['user_email'];
        $user_job = $donnees['user_job'];
        $id_user = $donnees['id_user'];
        $type_img = $donnees['img_type'];
        printOneProfile($user_description, $user_name, $user_surname, $user_email, $user_job, $id_user, $type_img);

        $req_work = model_one_profile_works($bdd, $id_user, $details);



        while ($donnees = $req_work->fetch(PDO::FETCH_ASSOC)) {
            $work_name = $donnees['work_name'];
            $work_id = $donnees['id_work'];
            printWork_OneProfile($work_name, $work_id);
        }
        printspace();
    }
} else {
    echo '
	<input type="hidden" id="current_page" />
	<input type="hidden" id="show_per_page" />
        
        <div id="pagination">';

    while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) {
        $profile = $donnees['id_user'];
        $user_login = $donnees['user_login'];
        $user_name = $donnees['user_name'];
        $user_surname = $donnees['user_surname'];
        $user_email = $donnees['user_email'];
        $user_job = $donnees['user_job'];
        $id_user = $donnees['id_user'];
        $type_img = $donnees['img_type'];
        $req_work = model_profiles_works($bdd, $id_user);

        printProfiles($user_name, $user_surname, $user_email, $user_job, $profile, $id_user, $type_img);

        while ($donnees = $req_work->fetch(PDO::FETCH_ASSOC)) {
            $work_name = $donnees['work_name'];
            $work_id = $donnees['id_work'];
            printWork_OneProfile($work_name, $work_id);
        }

        printspace();
    }
    echo '</div>
        
	<div class="menu_pagination"><div id="page_navigation"></div></div> ';
}
?>



